#ifndef CADVIEW_H
#define CADVIEW_H

#include <QGraphicsView>
#include <QGraphicsEllipseItem>
#include <QTimer>

class CADView : public QGraphicsView {
Q_OBJECT

public:
    CADView(QWidget *parent = nullptr);
    ~CADView();



protected:
    void wheelEvent(QWheelEvent *event) override;
    void drawBackground(QPainter *painter, const QRectF &rect) override;
    void mousePressEvent(QMouseEvent *event) override;

public slots:
    void drawLine(const QPointF &start, const QPointF &end);
    void drawArc(const QPointF &center, double radius, double startAngle, double spanAngle);
    void drawCircle(const QPointF &center, double radius);
    void drawCenterMark(const QPointF &center, double crossSize);


private:
    const int baseGridSize = 50; // 网格基础大小
    QGraphicsLineItem *horizontalLine = nullptr;
    QGraphicsLineItem *verticalLine = nullptr;
    QGraphicsEllipseItem *movingCircle = nullptr; // 移动中的圆形
    QPointF speed; // 移动速度
    QPointF targetPosition; // 目标位置
    QTimer *moveTimer; // 定时器
    double currentLineWidth = 2.0; // 当前线段宽度
};

#endif // CADVIEW_H
